package StructuralPattern.CompositePattern;

public class TestCompositePattern {
    public static void main(String[] args) {
        // 创建文件
        File file1 = new File("File1.txt");
        File file2 = new File("File2.txt");
        File file3 = new File("File3.txt");

        // 创建文件夹
        Folder folder1 = new Folder("Folder1");
        Folder folder2 = new Folder("Folder2");

        // 将文件添加到文件夹中
        folder1.add(file1);
        folder1.add(file2);

        folder2.add(file3);
        folder2.add(folder1); // 将folder1添加到folder2中

        // 创建根文件夹
        Folder rootFolder = new Folder("RootFolder");
        rootFolder.add(folder2);

        // 显示文件系统结构
        rootFolder.showDetails();
    }
}
